import {
  IsRequired,
  TypeUtils,
} from "./type-utils";
interface User {
  id: number; // 必选
  name: string; // 必选
  age?: number; // 可选
  email?: string; // 可选
  createdAt: Date; // 必选
}

// 测试
type UserRequiredKeys = TypeUtils<User>["RequiredKeys"];
// "id" | "name" | "createdAt"

type UserOptionalKeys = TypeUtils<User>["OptionalKeys"];
// "age" | "email"

type UserRequiredProps = TypeUtils<User>["RequiredProperties"];
// { id: number; name: string; createdAt: Date }

type UserOptionalProps = TypeUtils<User>["OptionalProperties"];
// { age?: number; email?: string }

type UserRequiredValues = TypeUtils<User>["RequiredValues"];
// number | string | Date

type UserOptionalValues = TypeUtils<User>["OptionalValues"];
// number | string

// 单个属性判断
type IsNameRequired = IsRequired<User, "name">; // true
type IsAgeRequired = IsRequired<User, "age">; // false
